package com.qipay.baas.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.qipay.baas.model.CpWithdrawTradlog;

public class CpWithdrawTradlogSqlProvider {

    public String insertSelective(CpWithdrawTradlog record) {
        BEGIN();
        INSERT_INTO("cp_withdraw_tradlog");
        
        if (record.getCpId() != null) {
            VALUES("cp_id", "#{cpId,jdbcType=BIGINT}");
        }
        
        if (record.getAmount() != null) {
            VALUES("amount", "#{amount,jdbcType=INTEGER}");
        }
        
        if (record.getFee() != null) {
            VALUES("fee", "#{fee,jdbcType=DECIMAL}");
        }
        
        if (record.getActualAmount() != null) {
            VALUES("actual_amount", "#{actualAmount,jdbcType=INTEGER}");
        }
        
        if (record.getType() != null) {
            VALUES("`type`", "#{type,jdbcType=TINYINT}");
        }
        
        if (record.getCardBank() != null) {
            VALUES("card_bank", "#{cardBank,jdbcType=VARCHAR}");
        }
        
        if (record.getCardSubBank() != null) {
            VALUES("card_sub_bank", "#{cardSubBank,jdbcType=VARCHAR}");
        }
        
        if (record.getCardBankNo() != null) {
            VALUES("card_bank_no", "#{cardBankNo,jdbcType=VARCHAR}");
        }
        
        if (record.getCardNo() != null) {
            VALUES("card_no", "#{cardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getIdCardNo() != null) {
            VALUES("id_card_no", "#{idCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            VALUES("`name`", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getMobile() != null) {
            VALUES("mobile", "#{mobile,jdbcType=VARCHAR}");
        }
        
        if (record.getTradeNo() != null) {
            VALUES("trade_no", "#{tradeNo,jdbcType=VARCHAR}");
        }
        
        if (record.getOutTradeNo() != null) {
            VALUES("out_trade_no", "#{outTradeNo,jdbcType=VARCHAR}");
        }
        
        if (record.getAttach() != null) {
            VALUES("attach", "#{attach,jdbcType=VARCHAR}");
        }
        
        if (record.getRemark() != null) {
            VALUES("remark", "#{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getState() != null) {
            VALUES("`state`", "#{state,jdbcType=TINYINT}");
        }
        
        if (record.getOperation() != null) {
            VALUES("`operation`", "#{operation,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getFinishTime() != null) {
            VALUES("finish_time", "#{finishTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(CpWithdrawTradlog record) {
        BEGIN();
        UPDATE("cp_withdraw_tradlog");
        
        if (record.getCpId() != null) {
            SET("cp_id = #{cpId,jdbcType=BIGINT}");
        }
        
        if (record.getAmount() != null) {
            SET("amount = #{amount,jdbcType=INTEGER}");
        }
        
        if (record.getFee() != null) {
            SET("fee = #{fee,jdbcType=DECIMAL}");
        }
        
        if (record.getActualAmount() != null) {
            SET("actual_amount = #{actualAmount,jdbcType=INTEGER}");
        }
        
        if (record.getType() != null) {
            SET("`type` = #{type,jdbcType=TINYINT}");
        }
        
        if (record.getCardBank() != null) {
            SET("card_bank = #{cardBank,jdbcType=VARCHAR}");
        }
        
        if (record.getCardSubBank() != null) {
            SET("card_sub_bank = #{cardSubBank,jdbcType=VARCHAR}");
        }
        
        if (record.getCardBankNo() != null) {
            SET("card_bank_no = #{cardBankNo,jdbcType=VARCHAR}");
        }
        
        if (record.getCardNo() != null) {
            SET("card_no = #{cardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getIdCardNo() != null) {
            SET("id_card_no = #{idCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            SET("`name` = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getMobile() != null) {
            SET("mobile = #{mobile,jdbcType=VARCHAR}");
        }
        
        if (record.getTradeNo() != null) {
            SET("trade_no = #{tradeNo,jdbcType=VARCHAR}");
        }
        
        if (record.getOutTradeNo() != null) {
            SET("out_trade_no = #{outTradeNo,jdbcType=VARCHAR}");
        }
        
        if (record.getAttach() != null) {
            SET("attach = #{attach,jdbcType=VARCHAR}");
        }
        
        if (record.getRemark() != null) {
            SET("remark = #{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getState() != null) {
            SET("`state` = #{state,jdbcType=TINYINT}");
        }
        
        if (record.getOperation() != null) {
            SET("`operation` = #{operation,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getFinishTime() != null) {
            SET("finish_time = #{finishTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }
}